home *** CD-ROM | disk | FTP | other *** search
- Path: zetnet.co.uk!demon!redrobe.demon.co.uk
- From: Mike@Redrobe.demon.co.uk (Mike)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Scalable GUI's
- Date: 25 Jan 96 15:44:58 +0000
- Message-ID: <5650.6598T944T2930@Redrobe.demon.co.uk>
- References: <4e67fm$544@columbia.acc.brad.ac.uk>
- NNTP-Posting-Host: redrobe.demon.co.uk
- X-NNTP-Posting-Host: redrobe.demon.co.uk
- X-Newsreader: THOR 2.22 (Amiga;TCP/IP)
-
-
- Hi, LA GUESTn , on 24-Jan-96 21:14:30 you scribbled....
- >I wish to produce GUI's that are font sensitive without using somebody elses
- >GUI libraries or GUI designers. The way I want to do it is to have functions
- >which will scale an (x,y) coord or width/height values by a standard
- >value...if anyone has achieved this could they help me out?
-
- >Any language (but asm - too difficult to follow!) is acceptable.
-
- Here's some code from one of my programs ( the GUI is from GadToolsBox,
- so some bits may be from that...))
-
- Its not that elegant but hey, its clean and bug-free (AFAIK anyway ;)
-
- --
- int ResizeGadgets(int newwidth,int newheight)
- {
- struct IntuiMessage *m;
- int (*func)();
- BOOL running = TRUE;
- struct Gadget *g;
- UWORD lc, tc;
- int count=0;
- long double xscale=1.0,yscale=1.0;
- struct NewGadget ng;
- long lasty=0;
-
- if ( ! ( g = CreateContext( &Project0GList )))
- return( 1L );
-
- xscale = ((long double)(newwidth)) /(long
- double)(ww+OffX);
- yscale = ((long double)(newheight)) /(long
- double)(wh+OffY);
- //printf("Scale = (X) %f : (Y)
- %f\n",xscale,yscale);
- for( lc = 0, tc = 0; lc < Project0_CNT; lc++ )
- {
-
- CopyMem((char * )&Project0NGad[ lc ],
- (char * )&ng, (long)sizeof( struct NewGadget ));
-
- ng.ng_VisualInfo = VisualInfo;
- ng.ng_TextAttr = Font;
- ng.ng_LeftEdge = (long double)(OffX
- + (ComputeX( ng.ng_LeftEdge )) * (long double)xscale);
- if ((Project0GTypes[lc] ==
- LISTVIEW_KIND)&&(yscale>1.0))
- ng.ng_TopEdge = lasty + 12;
- else
- ng.ng_TopEdge = (long
- double)(OffY + (ComputeY( ng.ng_TopEdge )) * (long double)yscale);
-
- if ( Project0GTypes[ lc ] !=
- GENERIC_KIND ) {
- ng.ng_Width = (UWORD)( (long
- double)ComputeX( ng.ng_Width) * (long double)xscale);
- if ((Project0GTypes[lc] !=
- LISTVIEW_KIND)&&(yscale>1.0))
- ng.ng_Height
- =(UWORD)((long double) ComputeY( ng.ng_Height) );
- else
- ng.ng_Height =
- (UWORD)((long double) ComputeY( ng.ng_Height) * (long double)yscale);
- }
- if (((ng.ng_TopEdge + ng.ng_Height) >
- lasty) && (Project0GTypes[lc] != LISTVIEW_KIND))
- lasty = ng.ng_TopEdge +
- ng.ng_Height;
- Project0Gadgets[ lc ] = g =
- CreateGadgetA((ULONG)Project0GTypes[ lc ], g, &ng, ( struct TagItem *
- )&Project0GTags[ tc ] );
-
- if ( Project0GTypes[ lc ] ==
- GENERIC_KIND ) {
- g->Flags |=
- GFLG_GADGIMAGE | GFLG_GADGHIMAGE;
- g->Activation |=
- GACT_RELVERIFY;
- g->GadgetRender =
- (APTR)getImage;
- g->SelectRender =
- (APTR)getImage;
- }
-
- while( Project0GTags[ tc ] ) tc += 2;
- tc++;
-
- if ( NOT g )
- return( 2L );
- }
- }
-
- void ResizeWindow(int newwidth,int newheight)
- {
- struct IntuiMessage *m;
- int (*func)();
- BOOL running = TRUE;
- struct Gadget *g;
- UWORD lc, tc;
- int count=0;
- long double xscale=1.0,yscale=1.0;
- struct NewGadget ng;
-
- StoreForResize();
- RemoveGList(Project0Wnd,Project0GList,-1);
- FreeGadgets( Project0GList );
- Project0GList=NULL;
-
- ResizeGadgets(newwidth,newheight);
-
- SetAPen(Project0Wnd->RPort,0L);
- RectFill(Project0Wnd->RPort,Project0Wnd-
- >BorderLeft,
- Project0Wnd->BorderTop,
- newwidth-Project0Wnd->BorderRight-1,
- newheight-Project0Wnd->BorderBottom-
- 1);
-
- RefreshWindowFrame(Project0Wnd);
- AddGList(Project0Wnd,Project0GList,-1,-
- 1,NULL);
- UserSetupWindow();
- RefreshGList(Project0GList,Project0Wnd,NULL,-
- 1);
- GT_RefreshWindow(Project0Wnd,NULL);
- }
- }
-
- --
-
-
-
- Mike
-
- --
- ---------------------------------------------------------------------------
- Mike Redrobe - Mike@Redrobe.demon.co.uk MikeRR on #Amiga
- ---------------------------------------------------------------------------
-
-